<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    用户名：<input type="text" id="username"><br>
    密码：<input type="password" id="pwd"><br>
    <button>注册</button>
    <script src="./js/axios.min.js"></script>
    <script>
        let btn = document.querySelector('button')
        let username = document.querySelector('#username')
        let password = document.querySelector('#pwd')
        btn.addEventListener('click',function(){
            axios({
                url:'http://hmajax.itheima.net/api/register',
                method: 'post',
                data:{
                    username:username.value.trim(),
                    password:password.value.trim()
                }
            }).then(res => {
                console.log(res);
            }).catch(err => {
                console.log(err.request);
            })
        })
    </script>
</body>
</html>